define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'system.sign/index',
        add_url: 'system.sign/add',
        edit_url: 'system.sign/edit',
        delete_url: 'system.sign/delete',
        self_sign_url: 'system.sign/selfSign',
        modify_url: 'system.sign/modify',
        export_url: 'system.sign/export',
        import_url: 'system.sign/import',
    };

    var Controller = {

        index: function () {

            ea.table.render({
                init: init,
                toolbar: ['refresh',
                    [{
                        text: '添加',
                        url: init.add_url,
                        method: 'open',
                        auth: 'add',
                        class: 'layui-btn layui-btn-normal layui-btn-sm',
                        icon: 'fa fa-plus',
                        extend: 'data-full="true"',
                    }],
                    'delete'
                    ,'export',
                    // [{
                    //     text: '导入',
                    //     url: init.import_url,
                    //     method: 'open',
                    //     auth: 'import',
                    //     class: 'layui-btn layui-btn-success layui-btn-sm',
                    //     icon: 'fa fa-plus',
                    //     extend: '',
                    // }]
                ],
                cols: [[
                    {type: "checkbox"},
                    {field: 'uid', width: 80, title: '用户id'},
                    {field: 'district', width: 80, title: '区县'},
                    {field: 'town', minWidth: 80, title: '乡镇'},
                    {field: 'community', minWidth: 80, title: '社区'},
                    {field: 'content', minWidth: 80, title: '工作内容'},
                    {field: 'image', minWidth: 80, title: '工作图片', search: false, templet: ea.table.image},
                    {field: 'type', title: '签到类型', minWidth: 80, search: 'select', selectList: {'签到': '签到', '签退': '签退'}},
                    {field: 'sign_date', minWidth: 80, title: '签到时间', search: 'range'},
                    {
                        width: 250,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            'edit',
                            'delete',
                            [
                                {
                                    title: '确认补签？',
                                    text:'补签',
                                    url: init.self_sign_url,
                                    method: 'request',
                                    class: 'layui-btn layui-btn-xs layui-btn-normal',
                                }
                            ]
                        ]
                    }
                ]],
            });
            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        import: function() {
            ea.listen();
        }
    };
    return Controller;
});